<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加挂号</title>
    <link href="bootstrap-4.6.1-dist/css/bootstrap.min.css"
          rel="stylesheet" type="text/css">
    <style type="text/css">
        #main{
            /*margin-top:20px;  //外边距*/
            /*background-color: red; //背景色*/
            background-color: #ececf6;
            /*padding-top:40px;  //内填充*/
            box-sizing:border-box;  //边框 使容器不变大
        }

    </style>
</head>
<body>
<div id="main">
    <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #e3f2fd;">
    <a class="navbar-brand" href="#">菜单</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
            aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="Doctor.html">医生管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="RegisterAdd.html">药品管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="Register.html">挂号管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link justify-content-end" href="login.html">退出</a>
            </li>
        </ul>
    </div>
    </nav>
    <form id="form">
        <div class="form-group row">    <!-- 表单组 行-->
            <label class="col-form-label col-2 text-center">病历号:</label>
            <div class="col-8">
                <input type="text" name="rid" class="form-control">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-form-label col-2 text-center">姓名：</label>
            <div class="col-8">
                <input type="text" name="name" class="form-control">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-form-label col-2 text-center">费用:</label>
            <div class="col-8">
                <input type="text" name="Money" class="form-control">
            </div>
        </div>
        <div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center">性别:</label>
                <div class="col-8">
                    <select name="sex" class="form-control">
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center">年龄:</label>
                <div class="col-8">
                    <input type="text" name="age" class="form-control">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center">科室:</label>
                <div class="col-8">
                    <select name="department" class="form-control" placeholder="请选择科室">
                        <option value="1">急诊</option>
                        <option value="2">儿科</option>
                        <option value="3">妇科</option>
                        <option value="4">皮肤科</option>
                        <option value="5">内分泌科</option>
                        <option value="6">牙科</option>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center">状态:</label>
                <div class="col-8">
                    <select name="status" class="form-control" placeholder="请选择状态">
                            <option value="1">挂号</option>
                            <option value="2">已住院</option>
                            <option value="2">已出院</option>
                            <option value="2">已结算</option>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center">注册日期:</label>
                <div class="col-8">
                    <input type="date" name="registerDate" class="form-control">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-form-label col-2 text-center"></label>
                <div class="col-8">
                    <button type="button" id="btnReg" class="btn btn-lg btn-info">提交</button>
                    <button type="reset"  class="btn btn-lg btn-danger">重置</button>
                    <a class="btn btn-primary" href="Register.html" role="button">返回</a>
                </div>
            </div>

        </div>
    </form>
</div>

</body>
<script src="jQuery/jquery-3.6.0.min.js"></script>
<script src="bootstrap-4.6.1-dist/js/bootstrap.min.js"></script>
<script>
    jQuery(function () {
        jQuery("#btnReg").click(function(){
            //获取页面中控件的数据
            //1.必须在<form></form>之间
            //2.必须有name属性
            let form=jQuery("#form").serialize();
            //向服务器发请求，并获取响应结果
            jQuery.post("register/add",form,function (rst) {
                if(rst>0)
                {
                    alert("添加成功！");
                    window.location.href="RegisterAdd.html";
                }
                else{
                    alert("添加失败！");
                }

            });
        });
    })
</script>
</html>